package org.community.controller;

import com.alibaba.fastjson.JSONObject;
import entity.CommonResult;
import lombok.Data;
import org.community.service.detail.DetailService;
import org.community.service.detail.userinfo.UserInfoService;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@Component("userInfoUtil")
@RequestMapping("/community/personal/userInfo")
@Data
public class UserInfoController {

    @Resource
    private UserInfoService userInfoService;


    @PostMapping("")
    public CommonResult<String> setUserInfo(@RequestBody JSONObject userInfo){
        return this.getUserInfoService().setUserInfo(userInfo);
    }

    /**
     *
     * @return map userInfoMap
     */
    public Map<String,Object> getUserInfo(Integer userInfo){
        Map<String,Object> infoMap = this.getUserInfoService().getUserInfo(userInfo);
        if(infoMap == null){
            return new HashMap<>();
        }
        return infoMap;
    }


}
